package com.iupon.tools.springevent.service;

import com.iupon.tools.springevent.entity.RequestVO;
import com.iupon.tools.springevent.event.PlayerOnLoginEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class PlayerOnLoginService {

    @Autowired
    ApplicationEventPublisher publisher;

    @Async
    public void initPlayerInfo(RequestVO requestVO) {
        log.info("异步推送玩家初始化数据信息..");
        final PlayerOnLoginEvent<RequestVO> playerOnLoginEvent = new PlayerOnLoginEvent<>(requestVO);
        publisher.publishEvent(playerOnLoginEvent);
    }
}
